package com.zhaowenhao.hello.demo.controller;

import com.zhaowenhao.hello.demo.service.IQueryService;
import com.zhaowenhao.hello.spring.framework.annotation.WHAutowired;
import com.zhaowenhao.hello.spring.framework.annotation.WHController;
import com.zhaowenhao.hello.spring.framework.annotation.WHRequestMapping;
import com.zhaowenhao.hello.spring.framework.annotation.WHRequestParam;
import com.zhaowenhao.hello.spring.framework.webmvc.servlet.WHModelAndView;

import java.util.HashMap;
import java.util.Map;

/**
 * 公布接口url
 */
@WHController
@WHRequestMapping("/")
public class PageController {

    @WHAutowired
    IQueryService queryService;

    @WHRequestMapping("/first")
    public WHModelAndView query(@WHRequestParam("name") String name) {
        System.out.println(name);
        String id = queryService.query(name);
        Map<String, Object> model = new HashMap<String, Object>();
        model.put("name", name);
        model.put("id", id);
        return new WHModelAndView("first.html", model);
    }

}
